<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>冷库温湿度阈值设置</title>
    <!-- 使用CDN引入CSS -->
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.6.0/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/font-awesome/5.15.3/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/datatables/1.10.21/css/jquery.dataTables.min.css">
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/datatables.net-buttons-bs4/2.2.3/buttons.bootstrap4.min.css">
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/bootstrap-select/1.13.18/css/bootstrap-select.min.css">
    <style>
        .card {
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            margin-bottom: 20px;
        }
        .card-header {
            background-color: #f8f9fa;
            border-bottom: 1px solid #e9ecef;
            padding: 15px 20px;
            border-top-left-radius: 8px;
            border-top-right-radius: 8px;
        }
        .card-body {
            padding: 20px;
        }
        .form-label {
            font-weight: bold;
        }
    </style>
</head>
<body>
    <div class="container-fluid">
        <h2 class="mt-4 mb-4">冷库温湿度阈值设置</h2>
        
        <div class="card mb-4">
            <div class="card-header">
                <i class="fas fa-filter mr-1"></i>筛选与操作
            </div>
            <div class="card-body">
                <div class="row mb-4">
                    <div class="col-md-3">
                        <div class="form-group">
                            <label for="warehouseSelect">选择仓库</label>
                            <select id="warehouseSelect" class="form-control">
                                <option value="">全部仓库</option>
                            </select>
                        </div>
                    </div>
                    <div class="col-md-3">
                        <div class="form-group">
                            <label>&nbsp;</label>
                            <button type="button" class="btn btn-primary btn-block" id="addBtn">
                                <i class="fas fa-plus"></i> 新增阈值设置
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- 阈值设置列表 -->
        <div class="card mb-4">
            <div class="card-header">
                <i class="fas fa-list mr-1"></i>阈值设置列表
            </div>
            <div class="card-body">
                <div class="table-responsive">
                    <table id="thresholdTable" class="table table-bordered" width="100%" cellspacing="0">
                        <thead>
                            <tr>
                                <th>设置ID</th>
                                <th>仓库名称</th>
                                <th>存储区域</th>
                                <th>温度范围(°C)</th>
                                <th>湿度范围(%)</th>
                                <th>预警级别</th>
                                <th>通知启用</th>
                                <th>通知方式</th>
                                <th>创建时间</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            <!-- 表格数据将通过JavaScript动态生成 -->
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
    
    <!-- 阈值设置模态框 -->
    <div class="modal fade" id="thresholdModal" tabindex="-1" role="dialog" aria-labelledby="thresholdModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-lg" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="thresholdModalLabel">阈值设置</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <form id="thresholdForm">
                        <input type="hidden" id="thresholdId" name="thresholdId">
                        <div class="row">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label for="warehouseId" class="form-label">仓库</label>
                                    <select class="form-control" id="warehouseId" name="warehouseId" required>
                                        <option value="">选择仓库</option>
                                    </select>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label for="storageArea" class="form-label">冷库区域</label>
                                    <input type="text" class="form-control" id="storageArea" name="storageArea" placeholder="例如：A区、B区" required>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label for="minTemperature" class="form-label">最低温度(°C)</label>
                                    <input type="number" step="0.1" class="form-control" id="minTemperature" name="minTemperature" required>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label for="maxTemperature" class="form-label">最高温度(°C)</label>
                                    <input type="number" step="0.1" class="form-control" id="maxTemperature" name="maxTemperature" required>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label for="minHumidity" class="form-label">最低湿度(%)</label>
                                    <input type="number" step="0.1" class="form-control" id="minHumidity" name="minHumidity" required>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label for="maxHumidity" class="form-label">最高湿度(%)</label>
                                    <input type="number" step="0.1" class="form-control" id="maxHumidity" name="maxHumidity" required>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label for="alarmLevel" class="form-label">预警级别</label>
                                    <select class="form-control" id="alarmLevel" name="alarmLevel" required>
                                        <option value="1">轻微</option>
                                        <option value="2">中等</option>
                                        <option value="3">严重</option>
                                    </select>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label for="notifyEnabled" class="form-label">启用通知</label>
                                    <select class="form-control" id="notifyEnabled" name="notifyEnabled" required>
                                        <option value="0">否</option>
                                        <option value="1">是</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label for="notifyType" class="form-label">通知方式</label>
                                    <select class="form-control selectpicker" id="notifyType" name="notifyType" multiple data-actions-box="true">
                                        <option value="1">短信</option>
                                        <option value="2">邮件</option>
                                        <option value="3">系统通知</option>
                                    </select>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label for="notifyReceivers" class="form-label">通知接收人</label>
                                    <input type="text" class="form-control" id="notifyReceivers" name="notifyReceivers" placeholder="多个接收人用逗号分隔">
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="remark" class="form-label">备注</label>
                            <textarea class="form-control" id="remark" name="remark" rows="3"></textarea>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" id="saveBtn">保存</button>
                </div>
            </div>
        </div>
    </div>

    <!-- 使用CDN引入JS -->
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/popper.js/1.16.1/umd/popper.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.6.0/js/bootstrap.bundle.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/datatables/1.10.21/js/jquery.dataTables.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/datatables.net-buttons/2.2.3/js/dataTables.buttons.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/datatables.net-buttons/2.2.3/js/buttons.html5.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/bootstrap-select/1.13.18/js/bootstrap-select.min.js"></script>
    <script th:src="@{/js/warehouse/coldStorageThreshold.js}"></script>
</body>
</html> 